﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
</head>
<body>

<h1>CIPl</h1>
<p>
CIPl provides a serialization and storage abstraction layer plus a rules engine. The “meta data” required by CIPl is mainly provided through attributes on CLR types, for example
</p>
<pre>
    [CIP4Item(AddAllProperties = true, Collection = "Organizations"),

    CIP4FileConnection(BaseDirectoryPath = "c:\\temp\\testfile")]

    public class OrganizationType

    {
</pre>

<p>
The client can also provide these parameters at run time, allowing, for example, sensitive information, such as passwords, to be passed in from a secure configuration store.
</p>
    <p>
        The rukes engine is used to express queries in a store-independent fashion.</p>
    <p>
        The primary objective of CIPl is to provide a scalable data store interface that 
        is independent of any specific underlying store. Apart from performance, it 
        should be possible to replace the underlying store without making any changes to 
        the application.
</p><p>
The main components of the environment are as follows:
</p>
<p>
<img src="cip4overview.jpg" style="width: 640px; margin-right: 0px" />    
    </p>
    <p>
The client uses a strongly typed interface provided by a CIPl StrongWrapper object. For example:
</p><pre>
<p style="margin-left: 40px">StrongWrapper&lt;ProductType&gt; productWrapper = new 
    StrongWrapper&lt;ProductType&gt;(Globals.DefaultLogger);
</p></pre><p>
The strong wrapper provides a serializer to serialize objects to and from an Xml or 
        Json representation. The objects are passed to a DataProvider which provides an abstraction over a store. 
</p><p>
The StrongWrapper object will either get required “meta data” from attributes on the object provided as a generic parameter at compile time, or from interactions with the client at run time. 
</p><p>
In the example above the OrganizationType has a CIP4FileConnection attribute that indicates that a file DataProvider provider will be used for the storage abstraction. 
</p><p>
The same information can be provided using a GetValues delegate provided by the StrongWrapper. The GetValues delegate returns an 
        enumeration value that indicates the type of DataProvider to use plus a dictionary populated with name-value pairs that will be used by the DataProvider to interact with the store. For example:
</p><pre>
                wrapper.GetValues = delegate(Dictionary<string, string> values)
                {
                    values.Add("Database", "CIPlDataProvider0401");
                    values.Add("Host", "patrickt\\sqlexpress");
	            return ProviderTypesEnum.Sql;
                };
</pre>
<p>
There are two types of serializers provided, namely Xml and Json serializers – The 
    serializers are generated on demand specifically for the type to be serialized. 
    The serializer is generated if the serializer is absent or the serializer code 
    is older than the code containing the type. A tool is added to Visual Studio at 
    install time that can be used to generate the serializers for all the types in 
    an assembly that have the CIP4Item attribute.&nbsp;
</p>
    <p>
There are several types of DataProvider available – for example:
</p>
    <ul>
        <li>Sql –each collection is mapped to a sql table in a SqlServer database. The required sql ddl is available in the install directory. The DataProvider uses the Host and Database parameters. You can also provide the ApplicationName, UserId and Password parameters.
        </li>
        <li>MySql –each collection is mapped to a sql table. The required MySql ddl is available in the install directory. The DataProvider uses the Host and Database parameters. You can also provide the UserId and Password parameters.
        </li>
        <li>File –each collection is mapped to a folder located in the BaseDirectoryFile folder . Each item is mapped to a separate file located in the collection’s folder. The DataProvider uses the BaseDirectoryFile parameter.
        </li>
        <li>XmlFile –each collection is mapped to an xml file. All items are mapped to an xml element in the collection’s xml file. 
            A single xml file can contain multiple collections. The DataProvider uses the XmlFileName parameter
        </li>
        <li>Dictionary – collections are mapped to a dictionary, items are mapped to a key-value pair in the dictionary with the key being the ExternalID.  The DataProvider uses the BaseDirectoryPath parameter.
        </li>
        <li>S3 –collections are mapped to S3 buckets, items are mapped to S3 objects. The DataProvider uses the AccessKey and SecretKey parameters 
        </li>
        <li>Mosso – collections are mapped to Mosso buckets, items are mapped to Mosso objects. The DataProvider uses the UserName and AccessKey parameters 
        </li>
        <li>Cassandra – collections are mapped to a ColumnFamily, items are mapped to a value in the collections ColumnFamily (called ‘text’) in Cassandra. The DataProvider uses the ColumnFamily parameter
        </li>
        <li>Mongo - collections are mapped to MongoDB collections. Items are serialized to 
            Json.
        </li>
    </ul>
    <p>
Each of the above is represented by a CIPl attribute that can be provided with the declaration of the type.
</p>
    <p>
        See the <a href="QuickStart.htm">Quick Start</a> page for a brief overview of building an application using 
        CIPl.</p>
    <p>
        See the <a href="Versioning.htm">Versioning</a> page for an overview of the CIPl item versioning feature.</p>



</body>
</html>
